Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adding vc create #148

Closed
wants to merge 21 commits into from
Closed

adding vc create #148

wants to merge 21 commits into from

Conversation

nitro-neal
Copy link
Contributor

@nitro-neal nitro-neal commented Jul 7, 2023

This change allows for a VC to be created with default values. Only the credentialSubject is required to create a credential

  • web5.vc.create() - Creates a Self Signed VC and stores it in local DWN
    • credentialSubject: any - the json object of the credentialSubject field
    • options?: CreateOptions - this will be the options for the other fields that consist of a VerifiableCredential like(“@context”, status, subject, expirationDate, id, issuanceDate, issuer, type, etc.)
    • returns a Record of the saved VC and the vc data object itself

Note:

  • options is not implemented in this PR.
  • signing is not implemented in this PR.

@codecov
Copy link

codecov bot commented Jul 7, 2023

Codecov Report

Merging #148 (002985e) into main (d8e2be7) will decrease coverage by 0.70%.
The diff coverage is 38.95%.

@@            Coverage Diff             @@
##             main     #148      +/-   ##
==========================================
- Coverage   82.28%   81.59%   -0.70%     
==========================================
  Files          68       68              
  Lines        6814     6992     +178     
  Branches      566      580      +14     
==========================================
+ Hits         5607     5705      +98     
- Misses       1205     1282      +77     
- Partials        2        5       +3     
Components Coverage Δ
common 100.00% <ø> (ø)
credentials 100.00% <100.00%> (+100.00%) ⬆️
crypto 95.24% <ø> (ø)
dids 50.20% <ø> (ø)
web5 82.21% <95.52%> (+0.66%) ⬆️
web5-agent 0.00% <0.00%> (ø)
web5-proxy-agent 0.00% <0.00%> (ø)
web5-user-agent 73.39% <14.28%> (-6.22%) ⬇️

packages/web5/src/web5.ts Outdated Show resolved Hide resolved
packages/web5/src/web5.ts Show resolved Hide resolved
packages/web5-user-agent/src/web5-user-agent.ts Outdated Show resolved Hide resolved
packages/web5-user-agent/src/web5-user-agent.ts Outdated Show resolved Hide resolved
packages/web5-user-agent/src/utils.ts Outdated Show resolved Hide resolved
@@ -280,6 +322,54 @@ export class Web5UserAgent implements Web5Agent {
return { message: dwnMessage.toJSON(), dataStream: readableStream };
}


// TODO: have issuer did key already stored in key manager and use that instead of generating a new one
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You got it -- you'd want to reference the key that's already stored.

Worth noting that there's a convention we've been using for signing DWN messages and encrypting DWN records, which is noted here:

  • export type DwnServiceEndpoint = {
    messageAttestationKeys?: string[]
    messageAuthorizationKeys?: string[] //! TODO: This property should be required by TS throws an error if it is.
    nodes: string[]
    recordEncryptionKeys?: string[] //! TODO: This property should be required by TS throws an error if it is.
    };
  • const services = [{
    'id' : 'dwn',
    'type' : 'DecentralizedWebNode',
    'serviceEndpoint' : {
    'nodes' : dwnUrls,
    'messageAuthorizationKeys' : ['#authz'],
    'recordEncryptionKeys' : ['#enc']
    }

To simplify we're going to combine messageAuthorizationKeys and messageAttestationKeys to messageSigningKeys since the same key can be used for both. Attestation is an option for a message if the author wants non-repudiable attestation. For now, you can resolve the DID document of the other, get the service endpoints using getServices() from the dids package and use the first index in the messageAuthorizationKeys array as the key reference to ask the KeyManager to sign with.

@mistermoe
Copy link
Member

Merging this will come after @frankhinek 's agent PR

@mistermoe mistermoe added the credentials SSI functionality label Aug 4, 2023
@frankhinek frankhinek added this to the 0.9 milestone Aug 28, 2023
@thehenrytsai
Copy link
Member

Super outdated, closing. Feel free to refresh and reopen.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
credentials SSI functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants